BlogHow to

Have Your Linux Terminal Read to You With the espeak Command

Summary

  • eSpeak lets you listen to your terminal commands instead of just reading them.
  • You can install eSpeak through your default package manager such as uisng APT, DNF, or YUM.
  • With various eSpeak options, you can adjust output speech, increase or decrease speech rate, and even choose different languages and accents.

Want to listen to log files, command output, file input, or anything you type in the terminal? The eSpeak program lets you do just that by providing a voice for your Linux system with numerous practical applications.

What Is eSpeak?

eSpeak is a command-line tool that lets you convert text to speech. It works by taking text input and converting it into phonemes, which are then synthesized into speech using formant synthesis. This method models the human vocal tract to produce speech sounds, resulting in a clear but somewhat mechanical voice.

Related

How to Read Text Messages Out Loud With Android

Want your Android phone to read your texts out loud?

Also, eSpeak can speak in many languages (over 100 languages and accents), so you can even learn how words sound in French or Spanish. You can also tweak the output by adjusting settings like the voice, speed, and pitch to get the sound just right.

How to Install eSpeak

espeak is easily available via almost any default package manager you might be using. For Debian-based systems (Ubuntu, Mint), use APT:

sudo apt install espeak
Installing eSpeak command-line tools using APT package manager on Ubuntu.

For Fedora or CentOS systems, use this:

sudo dnf install espeak

And for Arch users, it’s:

sudo pacman -S espeak

After installation, verify it by typing espeak –version in your terminal and pressing Enter. If installed, it will display the version number and the location of the eSpeak package.

Using eSpeak to Read the Text Aloud

Using espeak is as simple as typing a command. When you run eSpeak in the terminal, you provide it with some text, and it will speak that text out loud through your computer’s speakers.

For example, type espeak followed by the text in quotes without any additional options like this:

espeak "Hello and Welcome to this Linux guide."

Within seconds, your terminal will read the message aloud. You can even pipe text from files or other commands directly into eSpeak. It’s a fun and practical way to review logs, alerts, or even code comments without having to strain your eyes.

For instance, if you want to listen to the contents of a file, you could do:

cat yourfile.txt | espeak

Or, you can use this:

espeak -f text_file.txt

Not only text files, you can also pipe the output of any other commands to eSpeak. For example, to hear the current date and time, run:

date | espeak

This pipes the output of the date to espeak, which reads it aloud.

Exploring eSpeak Options

eSpeak also comes with handy features like a variety of voices (male, female, or effects like a whisper), and the option to save speech as a WAV file for later use. You can customize it with command-line options and fine-tune your experience. For example, you can adjust speech, speed up or slow down the voice, make it higher or lower, switch to different accents, or even combine multiple options.

To view all the available options eSpeak supports, run this:

espeak -help
Displaying manual page of eSpeak program on Ubuntu terminal.

And if you’re curious about the different voices available, simply run:

espeak --voices
Displaying all voices and accents list of eSpeak command.

Now from the list you can select your preferred voice and use it with the -v option followed by the voice name. For example, for a British English voice, run:

espeak -v en-gb "Hello, in a British accent!"

The default speaking speed is set to 175 WPM. You can adjust the speaking speed with the -s option, followed by words per minute. For example, to slow down the speed, use this:

espeak -s 120 "Speaking slower now."

Similarly, to speed up, use a value more than 175. But what if you want to adjust the pitch? Use the -p option. The default pitch is set to 50 with a range from 0 to 99. To increase pitch, use a value more than 50, and to decrease pitch, use a value less than 50.

Let’s increase pitch:

espeak -p 70 "Higher pitch."

To decrease pitch:

espeak -p 30 "Lower pitch."

To turn text into a WAV or MP3 file for later playback, use the -w option:

espeak "Backup completed successfully" -w alert.wav

You can also combine multiple options and let your terminal speak to you with customized settings. For instance, to get a British voice at a slower speed with higher pitch, use the -v, -s, and -p options altogether:

espeak -v en-gb -s 150 -p 60 "Combining voice, speed, and pitch options."

You can tweak these settings depending on what you’re doing—each adjustment brings a new flavor to your auditory experience.

Alternatives to eSpeak

While effective, espeak isn’t the only text-to-speech option. Tools like festival, say, gTTS, and flite provide text-to-speech systems with a wide range of voices. Try using festival if you want full customization and advanced control over voices beyond what eSpeak offers. You can easily install these alternatives with your default package manager.

say (Speech Dispatcher) is a system-wide service managing speech output, working with engines like espeak and festival. It enables consistent speech synthesis across applications and engine switching.

I’ve experimented with these alternatives, and they’re great for specific tasks. But for everyday use, I always come back to eSpeak because it’s lightweight and reliable.


Whether you’re reading files, practicing languages, or just having fun, this little tool can add a whole new dimension to your workflow. Further, if you enjoy using the terminal, you can also do other things right from the terminal, like playing Spotify or browsing the internet.


Source link

Related Articles

Back to top button
close